package com.appspot.moviesessions.provider;

import android.content.ContentUris;
import android.content.UriMatcher;
import android.net.Uri;

public class UriMappingImpl implements UriMapping {

	private UriMatcher uriMatcher;

	public UriMappingImpl(UriMatcher uriMatcher) {
		this.uriMatcher = uriMatcher;
		for (Match match : Match.values()) {
			this.uriMatcher.addURI(MovieSession.AUTHORITY, match.getPath(),
					match.ordinal());
		}
	}

	@Override
	public Match match(Uri uri) {
		return Match.values()[uriMatcher.match(uri)];
	}

	@Override
	public long parseId(Uri uri) {
		return ContentUris.parseId(uri);
	}
}
